package tv.yunxi.lib.entities.model

import android.os.Parcel
import android.os.Parcelable

class StorageInfo : Parcelable {
    var path: String? = null
    var mounted: String? = null
    var removable: Boolean = false
    var totalSize: Long = 0
    var availableSize: Long = 0


    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(this.path)
        dest.writeString(this.mounted)
        dest.writeByte(if (removable) 1.toByte() else 0.toByte())
        dest.writeLong(this.totalSize)
        dest.writeLong(this.availableSize)
    }

    constructor() {}

    protected constructor(`in`: Parcel) {
        this.path = `in`.readString()
        this.mounted = `in`.readString()
        this.removable = `in`.readByte().toInt() != 0
        this.totalSize = `in`.readLong()
        this.availableSize = `in`.readLong()
    }

    companion object {

        val CREATOR: Parcelable.Creator<StorageInfo> = object : Parcelable.Creator<StorageInfo> {
            override fun createFromParcel(source: Parcel): StorageInfo {
                return StorageInfo(source)
            }

            override fun newArray(size: Int): Array<StorageInfo?> {
                return arrayOfNulls(size)
            }
        }
    }
}
